package com.weiaibenpao.demo.chislim.ui.adapter;

import android.support.annotation.LayoutRes;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.weiaibenpao.demo.chislim.R;
import com.weiaibenpao.demo.chislim.bean.ChinaRankBean;
import com.weiaibenpao.demo.chislim.utils.Utils;

/**
 * Created by wlx on 2017/12/20.
 */

public class RunRankAdapter extends BaseQuickAdapter<ChinaRankBean.RankListBean,BaseViewHolder> {
    public RunRankAdapter(@LayoutRes int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder holder, ChinaRankBean.RankListBean chinaRankBean) {

        if (chinaRankBean.getRownum()==1||chinaRankBean.getRownum()==2||chinaRankBean.getRownum()==3) {
            ((TextView) holder.getView(R.id.text_rank)).setTextColor(mContext.getResources().getColor(R.color.themeColor));
        }else {
            ((TextView) holder.getView(R.id.text_rank)).setTextColor(mContext.getResources().getColor(R.color.color_light_gray));
        }
            holder.setText(R.id.text_rank,chinaRankBean.getRownum()+"").
                    setText(R.id.text_user_name,chinaRankBean.getUserName()).
                    setText(R.id.text_user_distance,"总里程"+Utils.decimalFormat(chinaRankBean.getFinishDistance())+"公里").
                    setText(R.id.text_user_totalTime, Utils.getHmsTime(chinaRankBean.getTotalTime()));
        Glide.with(mContext).load(chinaRankBean.getUserImage()).into((ImageView) holder.getView(R.id.img_user_head));

    }


}
